import React, { Component } from 'react';
import { Table, Tag, Space } from 'antd';
import { getTypeList } from "../api/reportType";
export default class ReportType extends Component {
    state = {
// 写在状态中,ajax请求可以更新
        data: null
    }

    componentDidMount() {

        getTypeList().then(
            (res) => {
                console.log("get article response:", res.data);
                this.setState({data: res.data});
            },
            (error) => {
                console.log("get response failed!");
            }
        );
    }

    render() {
        const columns = [
            {
                title: '类别id',
                dataIndex: 'id',
                key: 'id',
            },
            {
                title: '名称',
                dataIndex: 'name',
                key: 'name',
            },

            {
                title: '操作',
                key: 'action',
                render: (text, record) => (
                    <Space size="middle">
                             <a>删除</a>
                    </Space>
                ),
            },
        ];

        // const data = [
        //     {
        //         id: '1',
        //         name: 'John Brown'
        //     },
        //     {
        //         id: '2',
        //         name: 'Jim Green',
        //     },
        //     {
        //         id: '3',
        //         name: 'Joe Black',
        //     },
        // ];

        return (<h1>
            <Table columns={columns} dataSource={this.state.data} />

        </h1>)
    }
}
